var TheTableControl;

function initPage(){

	InitTableControl();
}

/**初始化数据列表空间**/
function InitTableControl(){
	TheTableControl=new TableController('TheTableControl');
	TheTableControl.objTable=document.all.t_data;
	TheTableControl.OnAfterRowSelected=afterSelectTheRow;
	if(TheTableControl.Count()>0)
	{
	//	TheTableControl.SelectARow(0);
	}else{
		initButtonStatus();
	}
}

/**根据选择的数据行的状态动态改变功能菜单的有效性**/
function afterSelectTheRow()
{
	//disableTD(document.all.deletePhotos);
}

/**初始化数据列表之后显示功能菜单的有效性**/
function initButtonStatus()
{
	if (TheTableControl.Count()<1)
	{   
		//disableTD(document.all.deletePhotos);
	}else
	{   
		//enableTD(document.all.deletePhotos);		
	}
}

/**===============START:用户事件代码==================**/

/**显示操作的图片库下面的图片**/
function showPhotoList(aid){
	alert(aid);
	window.location.href="buildingshowphoto.jsp?aid=" + aid;
}

/** 在把当前楼盘的专辑转换成相应的专辑 **/
function changeSpecid(specid,buildid,typeId){

	if( confirm( "您确实要把此专辑替换成新的楼盘图片库专辑码？" ) )
	{		
		var result = AjaxAction.syncCall('photoAction.enchangeSpecial',specid,buildid,typeId);
		if(result == 1){
			window.location.href = "./buildingpic1.jsp?id="+ buildid + "&picid="+ specid + "&typeid="+typeId;	
		}else{
			alert("操作失败！请向管理员反映。");
		}		
	}else{
		return;
	}	

}

/**显示操作的图片库下面的图片**/
function showPhotoDetail(photoIndex){
	alert("显示明细");
}

/**上传一个图片到图片库**/
function addNewPhoto(aid){
	var sURL="./portal/photo/newPhoto.jsp?aid="+aid;
	PopDivUp(1,sURL);
}

/**编辑一张图片信息**/
function editPhoto(aid){
	var sURL="./photoedit.jsp?aid="+aid;
	window.location.href = sURL;	
}

/** 删除一张图片 **/
function deletePhoto(aid,specid){
	if( confirm( "您确实要删除这张图片吗？" ) )
	{		
		AjaxAction.syncCall('photoAction.deletePhoto',aid);
		window.location.href = "./photolist.jsp?aid="+specid;	
	}else{
		return;
	}
}

/** 在楼盘中删除一张图片 **/
function deletePhoto(aid,specid,buildid){
	if( confirm( "您确实要删除这张图片吗？" ) )
	{		
		AjaxAction.syncCall('photoAction.deletePhoto',aid);
		window.location.href = "buildingpic1.jsp?id="+ buildid + "&picid="+ specid;
	}else{
		return;
	}
}

/** 后台管理中 设置图片为专辑封面 **/
function setPhotoSpec(aid,specid){
	AjaxAction.syncCall('photoAction.setPhotoAsFace',aid);
	alert("图片已设置为封面");
	window.location.href = "./photolist.jsp?aid="+specid;	
}

/**楼盘相册管理中-->修改当前专辑-->设置图片为专辑封面 **/
function setPhotoSpec(aid,specid){
	AjaxAction.syncCall('photoAction.setPhotoAsFace',aid);
	alert("图片已设置为封面");
	//window.location.href = "/eaip/house/photolist.jsp?aid="+specid;	
}




/** 删除选择的图片 **/
function deletePhotoBt(){
	var obj = document.getElementsByName('checkbox222');
	var objLen = obj.length;
	var i;
	var j = 0;
	var str = "";
	
	for(i=0; i<objLen; ++i){
		if(obj[i].checked==true){		
			str = str + obj[i].value + ";";
			++j;
		}
	}	
	
	if(j==0){
		alert("请选择要删除的专辑.");
		return;
	}
	

	if( confirm( "您确实要删除所选图片专辑吗？" ) )
	{		
		AjaxAction.syncCall('photoAction.deleteSelectPhotoes',str);
	//	window.location.href = "MAILBOX.com";	
	}else{
		return;
	}	
}






/**===============END:用户事件代码==================**/
function gotoPage(iPageNo)
{  
	with(document.all)
	{  
		var iPage=parseInt(PageNo.innerHTML);
		iPage=(isNaN(iPageNo))?1:((iPageNo<=0)?((iPageNo<0)?--iPage:++iPage):iPageNo)
		if(iPage<=parseInt(totalPage.innerHTML) && iPage>0)
		{
		
		location=location.pathname+"?PageNo=" +iPage + "&OrderField=" + document.getElementById("OrderField").value + "&OrderWise=" + document.getElementById("OrderWise").value;
		}
	}
}


/**当Form被提交时候执行**/
function onTheFormSubmit(){
	return true;
}

function OrderBy(strField)
{
	var oWise,strOrderWise;
	oWise=document.getElementById("OrderWise");

	if (document.getElementById("OrderField").value==strField)
	{
		if (oWise.value=="ASC")
			strOrderWise="DESC";
		else
			strOrderWise="ASC";
	}
	else
		strOrderWise="ASC";

	location=location.pathname+"?OrderField=" + strField + "&OrderWise=" + strOrderWise;

}


var parentDivArgs;
var CurrentOpenned;
function PopDivUp(a,cUrl) {
	var sURL;
	var icenter;
	var idialogWidth;
	var idialogHeight;
	var bShowScrollBar;
	var CnTitle;
	var EnTitle;
	var openMode;	//打开方式
	if(a>0){	
		switch(a) {
			//<上传一张图片>
			case   1: if(cUrl!=null) sURL=cUrl; else sURL="./portal/photo/newPhoto.jsp";openMode=0; idialogWidth="520px"; idialogHeight="340px"; break;
			//<编辑一张图片信息>
			case   2: if(cUrl!=null) sURL=cUrl; openMode=0; idialogWidth="520px"; idialogHeight="340px"; break;
		}
		if (document.all) {
			var V6Sorting;
			var strLanguage='';			
			CurrentOpenned = a;
			if (PopDivUp.arguments.length>1){
				strLanguage=PopDivUp.arguments[1];
				sURL = sURL + '&language='+strLanguage;
			}				
			openURL = sURL + getVerString(sURL);							
			switch (openMode){
				case 0:				
					OpenDivDialog(openURL,'',idialogWidth,idialogHeight,"",CnTitle,EnTitle);
					break;
				case 1:
					var leftWidth = (window.screen.width-parseInt(idialogWidth))/2;
					var topHeight = (window.screen.height-parseInt(idialogHeight))/2;
					window.open(openURL,'','resizable=yes,scrollbars=auto,menubar=no,directories=no,toolbar=no,location=no,status=1,center=yes,help=yes,left='+leftWidth+',top='+topHeight+',width='+idialogWidth+',height='+idialogHeight);					
					break;				
			}								
		}	
	}
}

